package com.wangxinenpu.springbootdemo.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.wangxinenpu.springbootdemo.dataobject.dto.function.FunctionSaveVo;
import com.wangxinenpu.springbootdemo.dataobject.dto.function.FunctionTreeVo;
import com.wangxinenpu.springbootdemo.dataobject.model.Function;
import com.wangxinenpu.springbootdemo.dataobject.model.Organization;
import com.wangxinenpu.springbootdemo.dataobject.vo.system.SystemVo;
import com.wangxinenpu.springbootdemo.service.FunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping ( "/function" )
@AllArgsConstructor
@Api ( value = "功能点管理", tags = "功能点管理" )
@Slf4j
public class FunctionController {

	private final FunctionService functionService;

	@PostMapping ( "/treeList" )
	@ApiOperation ( value = "树列表", notes = "树列表" )
	public R < List < FunctionTreeVo > > treeList () {
		return functionService.treeList ();
	}

	@PostMapping ( "/delete" )
	@ApiOperation ( value = "删除", notes = "删除" )
	public R < Boolean > delete ( @RequestBody String id ) {
		return functionService.delete ( id );
	}

	@PostMapping ( "/insert" )
	@ApiOperation ( value = "新增", notes = "新增" )
	public R < Boolean > insert ( @RequestBody @Validated FunctionSaveVo dto ) {
		return functionService.insert ( dto );
	}

	@PostMapping ( "/update" )
	@ApiOperation ( value = "编辑", notes = "编辑" )
	public R < Boolean > update ( @RequestBody @Validated FunctionSaveVo dto ) {
		return functionService.update ( dto );
	}

	@GetMapping ("detail")
	@ApiOperation ( value = "详情", notes = "详情" )
	public R < Function > detail ( @RequestParam String id) {
		return functionService.detail (id);
	}

}
